﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;

/// <summary>
/// Summary description for dangnhap
/// </summary>
public class dangnhap
{
    AccessData ad = new AccessData();
    public int KhachHangID { get; set; }
    public string TenDangNhap { get; set; }
    public string MatKhau { get; set; }
    public string HoTen { get; set; }
    public string Diachi { get; set; }
    public string SoDT { get; set; }
    public int QuyenHan { get; set; }
    public DateTime NgayTao { get; set; }
    public string Email { get; set; }

    public bool DangNhap(string a, string b)
    {
        SqlConnection connDB = ad.GetConnect();
        SqlCommand cmd = new SqlCommand("KHACHHANG_DNhap", connDB);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.Add("@TenDangNhap", System.Data.SqlDbType.NVarChar).Value = a;
        cmd.Parameters.Add("@MatKhau", System.Data.SqlDbType.NVarChar).Value = b;
        SqlDataReader reader;
        connDB.Open();
        reader = cmd.ExecuteReader();
        if (reader.Read())
        {
            KhachHangID = int.Parse(reader["KhachHangID"].ToString());
            TenDangNhap = reader["TenDangNhap"].ToString();
            MatKhau = reader["MatKhau"].ToString();
            HoTen = reader["HoTen"].ToString();
            Diachi = reader["Diachi"].ToString();
            SoDT = reader["SoDT"].ToString();
            NgayTao = DateTime.Parse(reader["NgayTao"].ToString());
            Email = reader["Email"].ToString();
            QuyenHan = int.Parse(reader["QuyenHan"].ToString());
            connDB.Close();
            return true;
        }
        else
        {
            connDB.Close();
            return false;
        }
    }

   
}